package personal.vivian.aop.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class SelfCallAOP {
    @Pointcut("execution(* personal.vivian.SelfCallService.*( ..))")
    public void pointCut(){

    }

    @Around("pointCut()")
    public void aroundAdvice(ProceedingJoinPoint pjp) {
        //获取签名的信息
        Signature signature = pjp.getSignature();
        System.out.println("被拦截的方法名为：" + signature.getName());
        try {
            pjp.proceed();
            System.out.println("方法执行完成:" + signature.getName());
        } catch (Throwable throwable) {
            throwable.printStackTrace();

        }
    }
}
